#ifndef uMigrationsH
#define uMigrationsH

#include "EIC.h"


class CBarre;
typedef void __fastcall(__closure *FonctionMigration)(CBarre *Barre);



class InfoMigration
{
public:
  FonctionMigration Fonction;
  unsigned int Version;
  bool Migrer;
  bool MigrerSiVersionInferieure;
};



// Version : ex : 0x0050601 pour 5.06a
// Exemple d'utilisation dans le cpp.
class PACKAGE_EIC CMigrations
{
protected:
  bool m_Dossier,m_VersionLisible,m_PlanterSiVersionSuperieure;
  TStringList *m_ListeMigrations;
  static AnsiString m_FichierCommun,m_FichierDossier;
  AnsiString m_Code,m_Section;
  #ifdef _DEBUG
    unsigned int m_VersionDEBUG;
    AnsiString m_DateDEBUG;
  #endif
  void __fastcall EcrireVersion(unsigned int Version) const;
  unsigned int __fastcall LireVersion() const;
  AnsiString __fastcall ChaineVersion(unsigned int Version) const;
public:
  __fastcall CMigrations(const AnsiString &Code,bool Dossier = true,const AnsiString &Section = "Migrations",bool VersionLisible = false);
  virtual __fastcall ~CMigrations();
  static void __fastcall Init(const AnsiString &FichierCommun,const AnsiString &FichierDossier);
  static void __fastcall GetInit(AnsiString &FichierCommun,AnsiString &FichierDossier);
  void __fastcall AjouterMigration(FonctionMigration Fonction,unsigned int Version,const AnsiString &Texte);
  virtual bool __fastcall Migrer(const AnsiString &Titre);
  void __fastcall Creer();
  void __fastcall RAZ();
  #ifdef _DEBUG
    __property unsigned int VersionDEBUG = {read = m_VersionDEBUG,write = m_VersionDEBUG};
    __property AnsiString DateDEBUG = {read = m_DateDEBUG,write = m_DateDEBUG};
  #endif
  __property unsigned int VersionActuelle = {read = LireVersion};
  __property bool PlanterSiVersionSuperieure = {read = m_PlanterSiVersionSuperieure,write = m_PlanterSiVersionSuperieure};
};



class PACKAGE_EIC CMigrationsDonnees : protected CMigrations
{
public:
  __fastcall CMigrationsDonnees(const AnsiString &Code,bool Dossier = true,const AnsiString &Section = "Migrations",bool VersionLisible = false) : CMigrations(Code,Dossier,Section,VersionLisible){}
  virtual __fastcall ~CMigrationsDonnees(){}
  void __fastcall Creer()
    {
      CMigrations::Creer();
    }
  void __fastcall RAZ()
    {
      CMigrations::RAZ();
    }
  void __fastcall AjouterMigration(FonctionMigration Fonction,unsigned int Version,const AnsiString &Texte,bool MigrerSiVersionInferieure);
  virtual bool __fastcall Migrer(const AnsiString &Titre);
  __property unsigned int VersionActuelle = {read = LireVersion};
};



#endif
